﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ShredTheLog.Common.MVVM;
using System.Diagnostics.Contracts;
using System.Collections.ObjectModel;
using System.Windows.Input;
using ShredTheLog.Api.DataContracts;
using System.ComponentModel.Composition;
using ShredTheLog.Api;

namespace ShredTheLog.ViewModels
{
    public sealed class ContactListViewModel : ViewModelBase, IDisposable
    {
        [Import]
        private IShredServices ShredServices { get; set; }

        public ReadOnlyObservableCollection<IContact> Contacts { get { return ShredServices.Contacts; } }

        private ICommand _closeCommand;
        public ICommand CloseCommand
        {
            get
            {
                if (_closeCommand == null)
                    _closeCommand = new DelegateCommand(Dispose);
                return _closeCommand;
            }
        }

        public void Dispose()
        {
            if (Closed != null)
                Closed(this, EventArgs.Empty);
        }

        public event EventHandler Closed;
    }
}
